package com.yang.thread.bulid;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @author yds
 * @program thread-study
 * @description 实现callable接口
 * @create 2020-09-22 16:20
 **/
public class ThreadTest3 implements Callable<Integer> {
    public Integer call() throws Exception {
        int i=0;
        for (; i < 200; i++) {
            System.out.println(Thread.currentThread().getName()+"正在看第"+i+"本书");
        }
        return i;
    }

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        ThreadTest3 t3=new ThreadTest3();
        FutureTask<Integer> futureTask=new FutureTask<Integer>(t3);
        new Thread(futureTask).start();
        System.out.println("当前线程返回值"+futureTask.get());
    }
}